cmake_minimum_required(VERSION 2.8)
project(selfCalib)

set(CMAKE_BUILD_TYPE "Debug")

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})

# cancel Warning information: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -g -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")

# cmake文件夹下的路径
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(OpenCV 3.2)
    if(NOT OpenCV_FOUND)
        message(FATAL_ERROR "OpenCV > 3.2 not found.")
    endif()
MESSAGE("OPENCV VERSION:")
MESSAGE(${OpenCV_VERSION})

# find_package(G2O REQUIRED)
find_package(Sophus REQUIRED)
# Find_Package(CSparse REQUIRED)

include_directories(
    ${PROJECT_SOURCE_DIR}
    ${PROJECT_SOURCE_DIR}/include
    # ${PROJECT_SOURCE_DIR}/Thirdparty/Sophus
    ${OpenCV_INCLUDE_DIRS}
    # ${G2O_INCLUDE_DIRS}
    ${Sophus_INCLUDE_DIRS}
    "/usr/include/eigen3/"
    # ${CSPARSE_INCLUDE_DIR}
)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
# set(G2O_LIBS g2o_csparse_extension g2o_stuff g2o_core cxsparse)

add_library(${PROJECT_NAME} SHARED 
    include/CameraTwoViewReconstruction.h
    include/readImageFeatures.h
    include/camera_pose_estimation.h
    include/acoustic_BA_g2o.h
    include/hand_eye_calibration.h   
    include/extrinsicRefinement.h
    src/CameraTwoViewReconstruction.cc
    src/readImageFeatures.cc
    src/camera_pose_estimation.cc
    src/acoustic_BA_g2o.cc
    src/hand_eye_calibration.cc
    src/extrinsicRefinement.cc
)

add_subdirectory(Thirdparty/g2o)

target_link_libraries(${PROJECT_NAME}
    ${OpenCV_LIBS}
    ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
    ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so
    # ${G2O_LIBS}
    -lboost_serialization
    -lcrypto
)

add_executable(MotionBasedExtrinCalib-v2 MotionBasedExtrinCalib-v2.cpp)
target_link_libraries(MotionBasedExtrinCalib-v2 ${PROJECT_NAME})

add_executable(FLS_PnP FLS_PnP.cpp)
target_link_libraries(FLS_PnP ${PROJECT_NAME})